home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
telecomm
/
uwsrc.arc
/
WINMAIN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1989-04-29
|
33KB
|
1,334 lines
/* multi-window terminal emulation Version 0.2, May 29th 1986
*
* (C) Copyright 1986 Hans-Martin Mosner, University of Dortmund, Germany
* You may freely use and distribute this program as source
* and/or binary provided you make no profit with it.
*/
#include <obdefs.h>
#include <gemdefs.h>
#include <osbind.h>
#include <stdio.h>
#include <bios.h>
#include <xbios.h>
#include "wind.h"
#include "uw.h"
#include "windefs.h"
#define FIRSTOBJ DABOUT
#define LASTOBJ PRTSTOP
/* global constants
*/
extern int gl_apid;
extern struct wi_str w[];
int contrl[12];
int intin[128];
int ptsin[128];
int intout[128];
int ptsout[128];
int work_in[11];
int work_out[57];
int pxyarray[20];
int msgbuff[8];
int phys_handle, handle;
/*
* Variables used by various routines (miscellaneous).
*/
long dummy; /* dummy return variable */
int scr_x, scr_y, scr_w, scr_h; /* size of screen */
int key; /* the key pressed */
int tmp; /* temporary for anything... */
char alert[300]; /* used for alerts */
int xsiz, ysiz; /* temporarys for size of window */
/*
* Character stuff (fonts, keymaps).
*/
FNT *fnttbl[10]; /* List of pointers to fonts avail */
int fontsavail; /* Number of fonts available */
FNT *tempfont; /* font pointer */
char *oldshifted; /* Pointer to old shifted key map. */
char *oldnormal; /* Pointer to old normal key map. */
char *oldcapslock; /* Pointer to old caps lock key map. */
int menu_key_map[0x80]; /* menu objects indexed by key map
(alt key) read from object file */
int fontmenuobj[] = /* array of font menu object numbers */
{ FNTBIG,
FNTSYS,
FNTOWN,
FNTALT,
FNTTINY,
FNTUNKNW,
/* Add new font menu items here! */
0
};
extern FNT *loadfont();
/*
* State (loosely defined).
*/
int tick; /* used for flashing cursor */
int outport; /* ports used with uw */
int inwind, outwind; /* windows for input/output */
int uw_runs; /* is uw running ? */
FNT *curfont; /* font in use */
int mouse; /* is mouse visible ? */
int menonoff; /* Menu toggle. */
int m1inout; /* mouse event enter = 0 exit = 1 */
int sel_inp_mode; /* input select with right button */
extern int highlighted_wdes; /* window with text highligted */
#define LOCKLEN 30 /* Max length of lock password */
char lockword[LOCKLEN]; /* lock password */
char lockbld[LOCKLEN]; /* lock password build area*/
extern int kermwdes; /* port number for kermit window */
/*
* Options (somewhat loosely defined).
*/
int fast; /* flag for fast open/close */
int overstrike; /* flag for character drawing */
int sliders; /* flag for sliders on new windows */
int titles; /* flag for titles on new windows */
int audibell; /* Audible bell. */
int visibell; /* Visible bell. */
int toponbel; /* Top window on bell. */
FUNCSTRING fstrings[NFSTRINGS]; /* storage for function key bodys */
char pastebuff[4096] = ""; /* 50 full lines of text */
char confpath[80] = ".\\*.*"; /* initial config file path */
char confname[40] = "win.cnf"; /* initial config file name */
int confbutt; /* button from fsel_input */
/*
* Screen forms, objects, and other similar goodies...
*/
MFDB screen_mf;
OBJECT *obj_tmp, *menubar;
TEDINFO *ted_tmp;
TEDINFO *ted_fnum;
extern struct iorec old_iorec; /* copy of old rs_232 io record from winio.c */
MFORM rmbmform[1];
MFORM lckmform[1];
#define CHECKWIN if (!outwind) break
/*
* The program code...
*/
extern char *getmem();
#ifdef MWC
#include <linea.h>
#endif
/*
* If LOCATE is defined, it is assumed to be the path to check after
* "." for standard files (fonts, config files, etc.).
*/
#ifndef LOCATE
#define locate(n) n
#else
char locpath[64] = LOCATE;
char *
locate (name)
char *name;
{
int fd;
static char new[80];
close(fd = open(name, 0));
if (fd >= 0)
return (name);
sprintf(new, "%s\\%s", locpath, name);
close(fd = open(new, 0));
return (fd >= 0? new: name);
}
#endif
startup()
{
int i,j;
char *tmpfnt;
static char my_shft_map[128];
static char my_norm_map[128];
#ifndef MWC
register GEMFONT **a5; /* this is really register A5 */
#endif
/* start up everything: appl_init, menu, and the like
*/
appl_init();
rsrc_load(locate("wind.rsc"));
rsrc_gaddr(R_TREE, MENUBAR, &menubar);
/*
* Fill menu_key_map by scaning object strings for ALTINDICATOR.
*/
for (i = FIRSTOBJ; i <= LASTOBJ; i++)
if (menubar[i].ob_type == G_STRING)
{
char * found;
char * index();
found = index((char *)menubar[i].ob_spec, ALTINDICATOR);
if (found != NULL)
{
menu_key_map[*(++found) & 0x7f] = i;
#ifdef DEBUG
printf("menu_key_map[%c] = %d\n", *found, i);
#endif
}
}
/* objc_change(menubar, VISIBELL, 0, 0, 0, 0, 0, CHECKED, 0); *already done*/
menu_bar(menubar, menonoff = 1);
m1inout = 1;
audibell = 1;
visibell = 1;
sliders = 1;
titles = 1;
/* set mouse symbol to arrow
*/
graf_mouse(ARROW, NULL);
mouse = 1;
/* get screen handle and sizes;
* open virtual workstation
*/
phys_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
wind_get(0, WF_WORKXYWH, &scr_x, &scr_y, &scr_w, &scr_h);
for (i=0; i<10; work_in[i++]=1);
work_in[10] = 2;
handle = phys_handle;
v_opnvwk(work_in, &handle, work_out);
/* set up screen mfdb
*/
screen_mf.ptr = NULL;
screen_mf.wpix = 640;
screen_mf.hpix = 400;
screen_mf.wwords = 40;
screen_mf.format = 0;
screen_mf.planes = 1;
/*
* now set up the system fonts
*/
fontsavail = 0;
if ((curfont = getmem((long)sizeof(FNT))) != NULL)
{
#ifdef MWC
linea0();
tmpfnt = la_init.li_a1[2]->font_data; /* 8 x 16 system font */
#else
asm("dc.w $a000"); /* get font addresses from line A */
asm("move.l a1,a5"); /* put it into A5 */
tmpfnt = a5[2]->ft_data;
#endif
for (i=0; i<128; i++)
for (j=0; j<16; j++)
curfont->f_data[i*16+j] = tmpfnt[i+j*256];
curfont->inc_x = 8;
curfont->inc_y = 16;
set_menu_string("8 x 16 sys font", fontmenuobj[fontsavail]);
curfont->def_win_x = 80; /* Set default window size */
curfont->def_win_y = 24;
gen_hash(curfont, &curfont->f_hash);
fnttbl[fontsavail] = curfont;
fontsavail++;
}
/* set up 6 x 6 system font */
if ((curfont = getmem((long)sizeof(FNT))) != NULL)
{
#ifdef MWC
linea0();
tmpfnt = la_init.li_a1[0]->font_data;
#else
asm("dc.w $a000"); /* get font addresses from line A */
asm("move.l a1,a5"); /* put it into A5 */
tmpfnt = a5[0]->ft_data;
#endif
for (i=0; i<128; i++){ /* for each character (first 128) */
int bitpos, index, offset;
bitpos = i*6;
index = bitpos >> 3;
offset = bitpos & ~(~0<<3);
for (j=0; j<6; j++) /* for each pixel row in character */
curfont->f_data[i*16+j+1] = ((tmpfnt[index+j*192] << offset) +
(tmpfnt[index+j*192+1] >> (8-offset) & ~(~0<<offset)))>>2 & 63;
curfont->f_data[i*16+0] = 0; /* extra empty row */
}
curfont->inc_x = 6;
curfont->inc_y = 7;
/*
* The 6x6 system font can be made better. (dot the i etc.)
* This is a bad hack, but it makes it easier to read.
*/
curfont->f_data[105*16+1] = 8;
curfont->f_data[105*16+2] = 0;
curfont->f_data[105*16+5] = 8;
curfont->f_data[106*16+5] = 20;
curfont->f_data[106*16+6] = 8;
curfont->f_data[106*16+2] = 0;
curfont->def_win_x = 80; /* Set default window size */
curfont->def_win_y = 40;
set_menu_string("6 x 7 sys font", fontmenuobj[fontsavail]);
gen_hash(curfont, &curfont->f_hash);
fnttbl[fontsavail] = curfont;
fontsavail++;
}
/*
* Load font file(s) if any.
*/
if (curfont = loadfont("windstd.fnt")) /* yes, I want the assignment (=). */
{
objc_change(menubar, fontmenuobj[fontsavail-1], 0, 0, 0, 0, 0, CHECKED, 0);
curfont->def_win_x = 80; /* Set default window size */
curfont->def_win_y = 24;
}
else {
objc_change(menubar, FNTSYS, 0, 0, 0, 0, 0, CHECKED, 0);
curfont = fnttbl[fontsavail - 1];
}
if (tempfont = loadfont("windalt.fnt"))
{
tempfont->def_win_x = 80; /* Set default window size */
tempfont->def_win_y = 32;
}
if (tempfont =